#ifndef CTABLETRIGGER_H
#define CTABLETRIGGER_H

#include "AbsTable.h"
#include <QMetaEnum>

struct StTrigger{
    QString id;
    QString session_id;
    QString conditions;
    QString reply;
    bool    is_hex;

    StTrigger loadData(QVariantList &varList)
    {
        if(varList.count() < 6){
            qWarning()<<"Size error!"<<varList.count()<<varList;
            return *this;
        }

        int nIndex = 0;
        id              = varList[nIndex++].value<QString>();
        session_id      = varList[nIndex++].value<QString>();
        conditions            = varList[nIndex++].value<QString>();
        reply            = varList[nIndex++].value<QString>();
        is_hex          = varList[nIndex++].value<bool>();

        return *this;
    }

    friend inline QDebug operator<<(QDebug &out, const StTrigger& info)
    {
        out <<" StQuick("<<info.id<<info.session_id<<info.conditions<<info.reply<<info.is_hex<<") ";
        return out;
    }
};
class CTableTrigger : public AbsTable
{
    Q_OBJECT
public:
    explicit CTableTrigger(QObject *parent = nullptr);

    static CTableTrigger* instance();

    bool createTable() override;

    bool deleteSession(QString strSessionId);
    bool addRows(QVector<StTrigger> &vecRows);
    QVector<StTrigger> queryRows(QString strSessionId);

};

#endif // CTABLETRIGGER_H
